import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
//---COMMON---
import { AppComponent } from './app.component';
import { NgProgressModule } from 'ngx-progressbar';

//---SERVICES---
import { UtilsService } from './shared/services/utils.service';
import { StorageService } from './shared/services/storage.service';
import { AuthenticationService } from './framework/login/login.service';

//---BASIC MODULES---
import { AppRoutesModule } from './app.routes';
import { LoginModule } from './framework/login/login.module';
import { FrameworkModule } from './framework/framework.module';
import { LoaderModule } from './shared/components/loader/loader.module';
import { SpinnerModule } from './shared/components/spinner/spinner.module';
import { AuthGuard } from './guards/auth.guard';
import { RouteGuard } from './guards/route.guard';

import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { AuthInterceptor } from './shared/interceptor/auth.interceptor';
import { GlobalErrorHandler } from './globalError.handler';
import { ToastModule } from 'ng2-toastr/ng2-toastr';
import { SortablejsModule } from 'angular-sortablejs';
import { SweetAlert2Module } from '@toverux/ngx-sweetalert2';
import { RefreshTokenService } from './shared/services/refreshToken.service';
import { RefreshTokenInterceptor } from './shared/interceptor/refresh.interceptor';
import { AnalyticsService } from './shared/services/googleAnalytics.service';
import { GoogleAnalyticsModule } from '../../node_modules/googleanalytics-angular/src/index';
import { SignalRService } from './shared/services/signalR.service';
import { UrlSerializer } from '@angular/router';
import { CustomUrlSerializer } from './shared/serializers/customUrlSrializer';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    HttpClientModule,
    NgProgressModule,
    BrowserAnimationsModule,
    ToastModule.forRoot(),
    SortablejsModule.forRoot({ animation: 150 }),
    SweetAlert2Module.forRoot({
      buttonsStyling: false,
      customClass: 'modal-content',
      confirmButtonClass: 'btn btn-primary',
      cancelButtonClass: 'btn btn btn-outline-dark-grey mr-3',
      reverseButtons: true,
      focusCancel: false,
      focusConfirm: false,
      showCancelButton: true
    }),
    AppRoutesModule,
    LoginModule,
    FrameworkModule,
    LoaderModule,
    SpinnerModule,
    GoogleAnalyticsModule.forRoot()
  ],
  providers: [
    AuthenticationService,
    StorageService,
    UtilsService,
    SignalRService,
    RefreshTokenService,
    AnalyticsService,
    AuthGuard,
    RouteGuard,
    { provide: UrlSerializer, useClass: CustomUrlSerializer },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: RefreshTokenInterceptor,
      multi: true
    },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: AuthInterceptor,
      multi: true
    }/*,
    {
      provide: ErrorHandler,
      useClass: GlobalErrorHandler
    }*/
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
